/* 
 * File:   User.h
 * Author: H
 *
 * Created on October 25, 2019, 8:32 AM
 */

#ifndef USER_H
#define	USER_H

#ifdef	__cplusplus
extern "C" {
#endif




#ifdef	__cplusplus
}
#endif

#endif	/* USER_H */
#include "pic16f886.h"
#define FA1_Pwr PORTCbits.RC0
#define Fault1_Signal PORTAbits.RA6
#define Yled1_Pwr PORTAbits.RA7
#define WG1_Check PORTAbits.RA0
#define WG1_TP1 PORTAbits.RA1
#define WG1_TP2 PORTAbits.RA2
#define WG1_TP3 PORTAbits.RA3
#define WG1_Ctr PORTAbits.RA4
#define Gled1_Check PORTAbits.RA5

#define FA2_Pwr PORTCbits.RC7
#define Fault2_Signal PORTCbits.RC5
#define Yled2_Pwr PORTCbits.RC6
#define Gled2_Check PORTBbits.RB0
#define WG2_Check PORTBbits.RB1
#define WG2_TP1 PORTBbits.RB2
#define WG2_TP2 PORTBbits.RB3
#define WG2_TP3 PORTBbits.RB4
#define WG2_Ctr PORTBbits.RB5

#ifndef Output
#define Output 0
#endif
#ifndef Input
#define Input 1
#endif

#define xFA1_Pwr(x);do{if (x == Output)TRISCbits.TRISC0 = Output;    else TRISCbits.TRISC0 = Input;}while(0);//PORTCbits.RC0
#define xFault1_Signal(x); do{if (x == Output)TRISAbits.TRISA6 = Output;    else TRISAbits.TRISA6 = Input;}while(0);//PORTAbits.RA6
#define xYled1_Pwr(x);do{if (x == Output)TRISAbits.TRISA7 = Output;    else TRISAbits.TRISA7 = Input;}while(0); //PORTAbits.RA7
#define xWG1_Check(x);do{if (x == Output)TRISAbits.TRISA0 = Output;    else TRISAbits.TRISA0 = Input;}while(0); //PORTAbits.RA0
#define xWG1_TP1(x); do{if (x == Output)TRISAbits.TRISA1 = Output;    else TRISAbits.TRISA1 = Input;}while(0);//PORTAbits.RA1
#define xWG1_TP2(x); do{if (x == Output)TRISAbits.TRISA2 = Output;    else TRISAbits.TRISA2 = Input;}while(0);//PORTAbits.RA2
#define xWG1_TP3(x); do{if (x == Output)TRISAbits.TRISA3 = Output;    else TRISAbits.TRISA3 = Input;}while(0);//PORTAbits.RA3
#define xWG1_Ctr(x); do{if (x == Output)TRISAbits.TRISA4 = Output;    else TRISAbits.TRISA4 = Input;}while(0);//PORTAbits.RA4
#define xGled1_Check(x);do{if (x == Output)TRISAbits.TRISA5 = Output;    else TRISAbits.TRISA5 = Input;}while(0);// PORTAbits.RA5

#define xFA2_Pwr(x); do{if (x == Output)TRISCbits.TRISC7 = Output;    else TRISAbits.TRISC7 = Input;}while(0);//PORTCbits.RC7
#define xFault2_Signal(x); do{if (x == Output)TRISCbits.TRISC5 = Output;    else TRISAbits.TRISC5 = Input;}while(0);//PORTCbits.RC5
#define xYled2_Pwr(x); do{if (x == Output)TRISCbits.TRISC6 = Output;    else TRISAbits.TRISC6 = Input;}while(0);//PORTCbits.RC6
#define xGled2_Check(x); do{if (x == Output)TRISbbits.TRISB0 = Output;    else TRISAbits.TRISB0 = Input;}while(0);//PORTBbits.RB0
#define xWG2_Check(x); do{if (x == Output)TRISbbits.TRISB1 = Output;    else TRISAbits.TRISB1 = Input;}while(0);//PORTBbits.RB1
#define xWG2_TP1(x); do{if (x == Output)TRISbbits.TRISB2 = Output;    else TRISAbits.TRISB2= Input;}while(0);//PORTBbits.RB2
#define xWG2_TP2(x); do{if (x == Output)TRISbbits.TRISB3 = Output;    else TRISAbits.TRISB3 = Input;}while(0);//PORTBbits.RB3
#define xWG2_TP3(x); do{if (x == Output)TRISbbits.TRISB4 = Output;    else TRISAbits.TRISB4 = Input;}while(0);//PORTBbits.RB4
#define xWG2_Ctr(x); do{if (x == Output)TRISbbits.TRISB5 = Output;    else TRISAbits.TRISB5 = Input;}while(0);//PORTBbits.RB5

#ifndef High
#define High 1
#endif
#ifndef Low
#define Low 0
#endif
#define FA1_Pwr_SetHigh();FA1_Pwr=High;
#define FA1_Pwr_SetLow();FA1_Pwr=Low;

#define Fault1_Signal_SetHigh();Fault1_Signal=High;
#define Fault1_Signal_SetLow();Fault1_Signal=Low;

#define Yled1_Pwr_SetHigh();Yled1_Pwr=High;
#define Yled1_Pwr_SetLow();Yled1_Pwr=Low;

#define FA2_Pwr_SetHigh();FA2_Pwr=High;
#define FA2_Pwr_SetLow();FA2_Pwr=Low;



extern void Port_Init(void);


